import React,{useEffect,useState} from 'react'
import "../../../api/index";
import request from "../../../untlis/request";
import { ProductCard } from 'react-vant';
import {useNavigate} from "react-router-dom"
// import {useDispatch} from  "react-redux"
interface DATATYPES{
    id:string;
    name:string;
    img:string;
}
export default function Class() {
    // const dispatch=useDispatch()
    const navigate=useNavigate()
    const [data,usedata]=useState<Array<DATATYPES>>([])
    useEffect(() => {
        console.log(123);
        request.get("/api/list").then(res=>{
            console.log(res);
            usedata(res.data.data)
        })
    }, [])
    const gotoxq=(item:any)=>{
        navigate(`/datelist/${item.id}`,{state:item})
    }
    return (
        <div>
        {
            data.map((item,index)=>{
                return <ProductCard
                onClick={()=>gotoxq(item)}
                key={index}
                num="1"
                price="2.00"
                desc="描述信息"
                title={item.name}
                thumb={item.img}
              />
            })
        }
    
        </div>
    )
}
